#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>

int main()
{
    printf("我变成了一个进程：%d\n", getpid());
    pid_t id = fork();
    if(id == 0)
    {
         sleep(2);
         printf("下面的代码都是子进程在执行:\n");
         char *myargv[] = {
         (char*)"./test/Test",
         (char*)"-a",
         (char*)"-b",
         NULL
         };
         
         char *myenv[] = {
             (char*)"PATH=/home/loukou-ruizi/linux-learning/course_control/Exec/test/Test",
             NULL
         };
         extern char**environ;
         execvpe("./test/Test", myargv, environ); //覆盖式的使用全新的环境变量表                                        
         execvpe("./test/Test", myargv, myenv); //使用父进程的环境变量表
        exit(3);
    }
    return 0;
}

